package com.virtual.rerijaapps.pet.ui;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.Button;

public class CustomButton extends Button
{
	private Context mContext;

	private int mStyle = 1;

    private static Typeface tf_bold;

    private static Typeface tf_cond_light;

    private static Typeface tf_count_light_italic;

	public CustomButton( Context context )
	{
		super( context, null );
		mContext = context;
		init();
	}

	public CustomButton( Context context, AttributeSet attrs )
	{
		super( context, attrs );
		mContext = context;
		mStyle = !isInEditMode() ? attrs.getAttributeIntValue( "http://schemas.android.com/apk/res/android", "textStyle", mStyle ) : mStyle;
		init();
	}

	protected void init()
	{
		if ( !isInEditMode() )
		{
            if ( 0 == mStyle )
            {
                if ( null == tf_cond_light )
                {
                    tf_cond_light = Typeface.createFromAsset( mContext.getAssets(), "fonts/OpenSans-CondLight.ttf" );
                }
                setTypeface( tf_cond_light );
            }
            else if ( 2 == mStyle )
            {
                if ( null == tf_count_light_italic )
                {
                    tf_count_light_italic = Typeface.createFromAsset( mContext.getAssets(), "fonts/OpenSans-CondLightItalic.ttf" );
                }
                setTypeface( tf_count_light_italic );
            }
            else
            {
                if ( null == tf_bold )
                {
                    tf_bold = Typeface.createFromAsset( mContext.getAssets(), "fonts/OpenSans-CondBold.ttf" );
                }
                setTypeface( tf_bold );
            }
		}
	}
}
